// Header Protection
#ifndef _WINDOW_H_
#define _WINDOW_H_

// Include Files
#include "Event\Event.h"

#include <Windows.h>

////////////////////////////////////////////////////////////////////////////////////////////////////
// Creates and manages a window and runs a thread to handle it's processing.
// Base Class - ISingleton<CWindow>: Makes this class a singleton.
////////////////////////////////////////////////////////////////////////////////////////////////////
class CWindow : public ISingleton<CWindow>, public ABCProcess
{
public:     // accessors
	// these are only going to be for getting handles and critical sections etc.

	HWND GetContext() { return m_hWindow; }

public:     // events
	CEvent<CEventArg> Close;

public:     // methods
	////////////////////////////////////////////////////////////////////////////////////////////////
	// Creates the game window and starts the thread using the current settings.
	void Create();

	////////////////////////////////////////////////////////////////////////////////////////////////
	// Destroys the game window and stops the thread.
	void Destroy();

	/////////////////////////////////////////////////////////////////////////////////
	// Makes the window visible.
	void Show();

	/////////////////////////////////////////////////////////////////////////////////
	// Makes the window invisible.
	void Hide();

private:    // friends
	friend class ISingleton<CWindow>;

private:    // static methods
	////////////////////////////////////////////////////////////////////////////////////////////////
	// Thread Procedure
	static uint_t __stdcall ThreadProc( void * _pWindow );

	////////////////////////////////////////////////////////////////////////////////////////////////
	// Window Procedure
	static LRESULT __stdcall WindowProc( 
		HWND _hWindow, UINT _nMessage, WPARAM _wParam, LPARAM _lParam );

private:    // methods
	////////////////////////////////////////////////////////////////////////////////////////////////
	// Constructor
	CWindow();

	////////////////////////////////////////////////////////////////////////////////////////////////
	// Destructor
	~CWindow();

	void ProcessBegin();

	void ProcessEnd();

	void ProcessTick( float_t _fTime );

private:    // dummy definitions
	CWindow( CWindow const & _rhs );
	CWindow & operator =( CWindow const & _rhs );

private:    // data
	HINSTANCE m_hApplication;
	HWND      m_hWindow;

	string_t m_strTitle;
	uint_t   m_uiWidth;
	uint_t   m_uiHeight;
	bool_t   m_bFullscreen;
};

// Header Protection
#endif // _WINDOW_H_
